import ArrayList from '@ohos.util.ArrayList'
import List from '@ohos.util.List'

export class ObjectUtils {
  static copy(empty: ESObject, source: ESObject) {
    Object.entries(source).forEach(([jsonKey, jsonValue]) => {
      empty[jsonKey] = jsonValue
    })
  }

  static copyArrayListToArray(source: ArrayList<ESObject>): Array<ESObject> {
    let copy = new Array<ESObject>()
    if (source != null && source.length > 0) {
      source.forEach((item) => {
        copy.push(item)
      })
    }
    return copy
  }

  static copyListToArray(source: List<ESObject>): Array<ESObject> {
    let copy = new Array<ESObject>()
    if (source != null && source.length > 0) {
      source.forEach((item) => {
        copy.push(item)
      })
    }
    return copy
  }
}